package com.zbkj.service.community.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.zbkj.common.model.community.CommunityQuestion;
import com.zbkj.common.request.CommunityQuestionSearchRequest;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.service.community.CommunityQuestionService;
import com.zbkj.service.dao.community.CommunityQuestionDao;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author keNan
* @description CommunityQuestionServiceImpl 接口实现
* @date 2025-06-26
*/
@Service
public class CommunityQuestionServiceImpl extends ServiceImpl<CommunityQuestionDao, CommunityQuestion> implements CommunityQuestionService {

    @Resource
    private CommunityQuestionDao dao;


    /**
    * 列表
    * @param request 请求参数
    * @param pageParamRequest 分页类参数
    * @author keNan
    * @since 2025-06-26
    * @return List<CommunityQuestion>
    */
    @Override
    public List<CommunityQuestion> getList(CommunityQuestionSearchRequest request, PageParamRequest pageParamRequest) {
        PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());

        //带 CommunityQuestion 类的多条件查询
        LambdaQueryWrapper<CommunityQuestion> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        CommunityQuestion model = new CommunityQuestion();
        BeanUtils.copyProperties(request, model);
        lambdaQueryWrapper.setEntity(model);
        return dao.selectList(lambdaQueryWrapper);
    }

}

